package com.tao.design.proxy.demo2;

import java.lang.reflect.Proxy;

/**
 * @ClassName MyDynamicProxy
 * @Description TODO
 * @Author Hugo
 * @Date 2023/3/25 18:31
 * @Version 1.0
 **/
public class MyDynamicProxy {


    public static void main(String[] args) {
        HelloImpl hello = new HelloImpl();
        MyInvocationHandler handler = new MyInvocationHandler(hello, new String[]{"测试输出"});
        Hello proxyInstance = (Hello)Proxy.newProxyInstance(HelloImpl.class.getClassLoader(), HelloImpl.class.getInterfaces(), handler);
        // 调用代理方法
//        proxyInstance.sayHello();
        String outString = proxyInstance.outString("你好啊!");
        System.out.println("客户端执行"+outString);
    }
}
